<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="新增置换信息表" bodyClass="white-bg"  libs=["prism","bootstrapSelect","ueditor"]/>
<div class="wrapper wrapper-content ibox-content">
    <@form.form id="form-substitution-add"  class="form-horizontal">
    <input name="id" type="hidden" value="${bpmCrmSubstitution.id}">
    <input name="processStatus" class="form-control" type="hidden">
    <input id="processStatusValue" value="${bpmCrmSubstitution.processStatus}" class="form-control" type="hidden">
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "流水号"/>：
    </label>
        <div class="col-sm-8"><input class="form-control" name="saleOrderNumber" type="text" value="${bpmCrmSubstitution.saleOrderNumber?default('')}" readonly="true">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "销售员"/>：
    </label>
        <div class="col-sm-8"><input class="form-control" type="text" value="${bpmCrmSubstitution.saleUsername?default('')}" readonly="true">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "销售订单编号"/>：
    </label>
        <div class="col-sm-8"><input class="form-control" type="text" value="${bpmCrmSubstitution.saleCode?default('')}" readonly="true">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "车辆识别号"/>：
    </label>
        <div class="col-sm-8"><input class="form-control" type="text" value="${bpmCrmSubstitution.outCarVin?default('')}" readonly="true" >
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "车型"/>：
    </label>
        <div class="col-sm-8"><input class="form-control" type="text" value="${bpmCrmSubstitution.outCarVehicle?default('')}" readonly="true">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "换入车辆识别号"/>：
    </label>
        <div class="col-sm-8"><input class="form-control" type="text" value="${bpmCrmSubstitution.inCarVin?default('')}"  readonly="true">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "换入车辆/车型"/>：
    </label>
        <div class="col-sm-8"><input class="form-control" type="text" value="${bpmCrmSubstitution.inCarVehicle?default('')}"  readonly="true">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "车辆里程"/>：
    </label>
        <div class="col-sm-8"><input class="form-control" type="text" value="${bpmCrmSubstitution.inCarMileage?default('')}"  readonly="true">
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "要价/置换价"/>：
    </label>
        <div class="col-sm-8"><input class="form-control" type="text" value="${bpmCrmSubstitution.inCarAskprice?default('')}"  readonly="true">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "折价备注"/>：</label>
        <div class="col-sm-8">
            <textarea class="form-control" readonly="true">${bpmCrmSubstitution.inCarTradememo?default('')}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "审核备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="purchaseRemark" class="form-control" readonly="true">${bpmCrmSubstitution.purchaseRemark?default('')}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "是否收购"/>：</label>
        <div class="col-sm-8">
            <@form.radio name="purchaseIsbuy" dictType="sys_crm_isOrNo" readOnly="true" value="${bpmCrmSubstitution.purchaseIsbuy?default('')}" />
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "估价"/>：
    </label>
        <div class="col-sm-8"><input name="purchaseEvaluation" class="form-control" type="text" value="${bpmCrmSubstitution.purchaseEvaluation?default('')}" readonly="true">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "入库检查"/>：</label>
        <div class="col-sm-8">
            <@form.radio name="warehouseInCheck" dictType="sys_bpm_crm_passorclose" readOnly="true" value="${bpmCrmSubstitution.warehouseInCheck?default('')}" />
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "入库估价"/>：
    </label>
        <div class="col-sm-8"><input name="warehouseInEvaluation" class="form-control" type="text"  value="${bpmCrmSubstitution.warehouseInEvaluation?default('')}" readonly="true">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "入库备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="warehouseInRemark" class="form-control" readonly="true">${bpmCrmSubstitution.warehouseInRemark?default('')}</textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "入库文件"/>：</label>
        <div class="col-sm-8">
            <@form.radio name="warehouseInFile" dictType="sys_bpm_crm_passorclose" readOnly="true" value="${bpmCrmSubstitution.warehouseInFile?default('')}" />
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "入库备注"/>：
    </label>
        <div class="col-sm-8"><input name="filehumanInRemark" class="form-control" type="text" value="${bpmCrmSubstitution.filehumanInRemark?default('')}" readonly="true" >
        </div>
    </div>
<#if bpmCrmSubstitution.processStatus==4 >
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳审核"/>：</label>
        <div class="col-sm-8">
            <@form.radio name="checkmoneyCashierReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmSubstitution.checkmoneyCashierReview?default('1')}" />
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "证明"/>：
    </label>
        <div class="col-sm-8">

            <div class="layui-upload">
                <button type="button" class="btn btn-success btn-sm" id="proofList"><i class="fa fa-upload"></i>上传证明</button>
                <div class="layui-upload-list layui-upList-minHeight uploadpadding">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>文件名</th>
                            <th>大小</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="demoproofList">
                        </tbody>
                    </table>
                </div>
                <div class="layui-form-item layui-btn-Center">
                    <div class="layui-input-block text-right">
                        <button type="button" class="layui-btn layui-btn-xs" id="proofListAction">开始上传</button>
                    </div>
                </div>
            </div>

        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "贷款金额"/>：
    </label>
        <div class="col-sm-8"><input name="checkmoneyLoanamountreceived" class="form-control" type="number" required >
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收据编号"/>：
    </label>
        <div class="col-sm-8"><input name="checkmoneyReceiptnumber" class="form-control" type="text" required >
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳备注/备忘录"/>：</label>
        <div class="col-sm-8">
            <textarea name="checkmoneyMemo" class="form-control" required></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "订单生效日"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="orderTakeEffectTime"  data-type="date" data-format="yyyy-MM-dd" type="text" required/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收款日"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="collectionTime"  data-type="date" data-format="yyyy-MM-dd" type="text" required/>
            </div>
        </div>
    </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "间隔日"/>：
    </label>
        <div class="col-sm-8"><input name="intervalDay" class="form-control" type="number" required>
        </div>
    </div>
    <div class="form-group"><label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "利息率"/>：
    </label>
        <div class="col-sm-8"><input name="interestRate" class="form-control" type="number" value="${bpmCrmSubstitution.interestRate?default('0.008')}" required>
        </div>
    </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "资金成本"/>：
    </label>
        <div class="col-sm-8"><input name="costOfCapital" class="form-control" type="number" required>
        </div>
    </div>
</#if>
<#if bpmCrmSubstitution.processStatus==5 >
<div class="form-group">
    <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳审核"/>：</label>
    <div class="col-sm-8">
        <@form.radio name="checkmoneyCashierReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmSubstitution.checkmoneyCashierReview?default('')}" />
    </div>
</div>
<div class="form-group"><label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "证明"/>：
</label>
    <div class="col-sm-8">

        <div class="layui-upload">
            <button type="button" class="btn btn-success btn-sm" id="proofList"><i class="fa fa-upload"></i>上传证明</button>
            <div class="layui-upload-list layui-upList-minHeight uploadpadding">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>文件名</th>
                        <th>大小</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="demoproofList">
                    <#list proof as item>
                    <tr id="upload${item_index}">
                        <td> ${item.fileName?default("")}</td>
                        <td> ${item.fileSize?default("")}</td>
                        <td>已上传</td>
                        <td>
                            <a class="btn btn-danger btn-sm" href="#" download="${item.url}"><i class="fa fa-download"></i></a>
                        </td>
                    </tr>
                    </#list>
                    </tbody>
                </table>
            </div>
            <div class="layui-form-item layui-btn-Center">
                <div class="layui-input-block text-right">
                    <button type="button" class="layui-btn layui-btn-xs" id="proofListAction">开始上传</button>
                </div>
            </div>
        </div>

    </div>
</div>
<div class="form-group"><label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "贷款金额审核"/>：
</label>
    <div class="col-sm-8"><input name="checkmoneyLoanamountreceived" class="form-control" type="text" value="${bpmCrmSubstitution.checkmoneyLoanamountreceived?default('')}" required >
    </div>
</div>
<div class="form-group"><label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收据编号"/>：
</label>
    <div class="col-sm-8"><input name="checkmoneyReceiptnumber" class="form-control" type="text" required value="${bpmCrmSubstitution.checkmoneyReceiptnumber?default('')}" >
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳备注/备忘录"/>：</label>
    <div class="col-sm-8">
        <textarea name="checkmoneyMemo" class="form-control" required>${bpmCrmSubstitution.checkmoneyMemo?default('')}</textarea>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "订单生效日"/>：</label>
    <div class="col-sm-8">
        <div class="input-group date">
            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
            <input class="form-control time-input" id="orderTakeEffectTime" name="orderTakeEffectTime"  data-type="date" data-format="yyyy-MM-dd" type="text"  value="${(bpmCrmSubstitution.orderTakeEffectTime?string('yyyy-MM-dd'))!}" required/>
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收款日"/>：</label>
    <div class="col-sm-8">
        <div class="input-group date">
            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
            <input class="form-control time-input" id="collectionTime" name="collectionTime"  data-type="date" data-format="yyyy-MM-dd" type="text"  value="${(bpmCrmSubstitution.collectionTime?string('yyyy-MM-dd'))!}" required/>
        </div>
    </div>
</div>
<div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "间隔日"/>：
</label>
    <div class="col-sm-8"><input name="intervalDay" class="form-control" type="number" value="${bpmCrmSubstitution.intervalDay?default('')}" required>
    </div>
</div>
<div class="form-group"><label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "利息率"/>：
</label>
    <div class="col-sm-8"><input name="interestRate" class="form-control" type="text" value="${bpmCrmSubstitution.interestRate?default('0.008')}" required>
    </div>
</div>
<div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "资金成本"/>：
</label>
    <div class="col-sm-8"><input name="costOfCapital" class="form-control" type="number" value="${costOfCapital}" required>
    </div>
</div>
</#if>
<#if bpmCrmSubstitution.processStatus!=4 && bpmCrmSubstitution.processStatus!=5 >

<div class="form-group">
    <label class="col-sm-3 control-label"><@ctx.i18n text = "出纳审核"/>：</label>
    <div class="col-sm-8">
        <@form.radio name="checkmoneyCashierReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmSubstitution.checkmoneyCashierReview?default('')}" readOnly="true" />
    </div>
</div>
<div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "证明"/>：
</label>
    <div class="col-sm-8">

        <div class="layui-upload">
            <div class="layui-upload-list layui-upList-minHeight uploadpadding">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>文件名</th>
                        <th>大小</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="demojiazhaoList1">
                    <tr id="upjiazhaoload1"></tr>
                    <#list proof as item>
                    <tr id="upload${item_index}1">
                        <td> ${item.fileName?default("")}</td>
                        <td> ${item.fileSize?default("")}</td>
                        <td>已上传</td>
                        <td>
                            <a class="btn btn-danger btn-sm" href="#" download="${item.url}"><i class="fa fa-download"></i></a>
                        </td>
                    </tr>
                    </#list>
                    </tbody>
                </table>
            </div>
        </div>

    </div>
</div>
<div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "贷款金额审核"/>：
</label>
    <div class="col-sm-8"><input name="checkmoneyLoanamountreceived" class="form-control" type="text" value="${bpmCrmSubstitution.checkmoneyLoanamountreceived?default('')}" readonly="true" >
    </div>
</div>
<div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "收据编号"/>：
</label>
    <div class="col-sm-8"><input name="checkmoneyReceiptnumber" class="form-control" type="text" value="${bpmCrmSubstitution.checkmoneyReceiptnumber?default('')}" readonly="true" >
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label"><@ctx.i18n text = "出纳备注/备忘录"/>：</label>
    <div class="col-sm-8">
        <textarea name="checkmoneyMemo" class="form-control" readonly="true">${bpmCrmSubstitution.checkmoneyMemo?default('')}</textarea>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"><@ctx.i18n text = "订单生效日"/>：</label>
    <div class="col-sm-8">
        <div class="input-group date">
            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
            <input class="form-control" name="orderTakeEffectTime"  data-type="date" data-format="yyyy-MM-dd" value="${(bpmCrmSubstitution.orderTakeEffectTime?string('yyyy-MM-dd'))!}" type="text" readonly="true" />
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label"><@ctx.i18n text = "收款日"/>：</label>
    <div class="col-sm-8">
        <div class="input-group date">
            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
            <input class="form-control" name="collectionTime"  data-type="date" data-format="yyyy-MM-dd" value="${(bpmCrmSubstitution.collectionTime?string('yyyy-MM-dd'))!}" type="text" readonly="true" />
        </div>
    </div>
</div>
<div class="form-group">        <label class="col-sm-3 control-label"><@ctx.i18n text = "间隔日"/>：
</label>
    <div class="col-sm-8"><input name="intervalDay" class="form-control" type="text"  value="${bpmCrmSubstitution.intervalDay?default('')}" readonly="true">
    </div>
</div>
<div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "利息率"/>：
</label>
    <div class="col-sm-8"><input name="interestRate" class="form-control" type="text" value="${bpmCrmSubstitution.interestRate?default('')}" readonly="true">
    </div>
</div>
<div class="form-group">        <label class="col-sm-3 control-label"><@ctx.i18n text = "资金成本"/>：
</label>
    <div class="col-sm-8"><input name="costOfCapital" class="form-control" type="text"  value="${bpmCrmSubstitution.costOfCapital?default('')}" readonly="true">
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label"><@ctx.i18n text = "财务经理审核"/>：</label>
    <div class="col-sm-8">
        <@form.radio name="financeManagerReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmSubstitution.financeManagerReview?default('')}" readOnly="true"/>
    </div>
</div>
<div class="form-group"><label class="col-sm-3 control-label"><@ctx.i18n text = "经理复核"/>：
</label>
    <div class="col-sm-8"><input name="managerReview" class="form-control" type="text" value="${bpmCrmSubstitution.managerReview?default('')}" readonly="true">
    </div>
</div>
</#if>


</@form.form>
</div>
<@footer>
<script type="text/javascript">

    $(function () {

        $("[name='intervalDay']").blur(function () {
            costOfCapitalResult();
        })
        $("[name='interestRate']").blur(function () {
            costOfCapitalResult();
        })
        $("[name='orderTakeEffectTime']").blur(function () {
            intervalDayResult();
        })
        $("[name='collectionTime']").blur(function () {
            intervalDayResult();
        })
    })

    function intervalDayResult(){
        console.log("调用计算日期")
        var orderTakeEffectTimeValue=$("[name='orderTakeEffectTime']").val();
        var collectionTimeValue=$("[name='collectionTime']").val();
        console.log("订单生效日",orderTakeEffectTimeValue,"收款日",collectionTimeValue)
        if(isNullOrEmpty(orderTakeEffectTimeValue)||isNullOrEmpty(collectionTimeValue)){
            $("[name='intervalDay']").val("");
        }
        else{
            var timeValue=new Date(collectionTimeValue)-new Date(orderTakeEffectTimeValue);
            var jisuanjieguo=Math.ceil(timeValue/(1000*24*3600));
            $("[name='intervalDay']").val(jisuanjieguo);
            costOfCapitalResult();
        }
    }
    function costOfCapitalResult() {
        console.log("调用计算金额")
        var loanMoneyValue=$("[name='checkmoneyLoanamountreceived']").val();
        var intervalDayValue=$("[name='intervalDay']").val();
        var interestRateValue=$("[name='interestRate']").val();
        if(isNullOrEmpty(loanMoneyValue)||isNullOrEmpty(intervalDayValue)||isNullOrEmpty(interestRateValue)){
            $("[name='costOfCapital']").val("");
        }
        else{
            var jisuanjieguo=parseFloat(loanMoneyValue)*parseFloat(intervalDayValue)*parseFloat(interestRateValue);
            $("[name='costOfCapital']").val(jisuanjieguo);
        }
    }

    var prefix = baseURL + "bpm/substitution"
    $("#form-substitution-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        var processStatusValue=parseInt($("#processStatusValue").val());
        processStatusValue=(processStatusValue==4||processStatusValue==5)?(processStatusValue+1):processStatusValue;
        $("[name='processStatus']").val(processStatusValue);
        if (opt.validate.form()) {
            opt.operate.save(prefix + "/edit", $('#form-substitution-add').serialize());
        }
    }
    function isNullOrEmpty(value) {
        return value==''||value==null||value==undefined;
    }
    //在插件中使用对象
    $.fn.upfile = function(type) {
        var upfile = new Upfile(this,'',$("input[name='saleOrderNumber']").val(),type);
        layui.use('upload', function() {
            var upload = layui.upload;
            var UplodeIn = upload.render(upfile.options);
            upfile.SetInst(UplodeIn);

        });

    };
    /**
     * 凭证
     */
    $('#proofList').upfile(15);

</script>
</@footer>
</@pageTheme>